<?php
Yii::app()->clientScript->registerScriptFile((Yii::app()->baseUrl) . '/vendor/ckeditor/ckeditor.js', CClientScript::POS_HEAD);

Yii::app()->clientScript->registerScriptFile((Yii::app()->baseUrl) . '/vendor/ckeditor/adapters/jquery.js', CClientScript::POS_HEAD);
?>
<link href="<?php echo CSS_User_URL; ?> /Article_Details_style.css" rel="stylesheet" type="text/css">              
<section id="main_cover" class="cover center-child">
    <div class="cover_intro">
        <div id="someone_image" class="center-child image_parent">
            <img src="<?php echo Yii::app()->baseUrl; ?>/images/People_demo.jpg" alt="Ideawebsite.com">
        </div>
        <div id="someone_things">
            <h1 class="someone_slogan">Always do the best</h1>
            <span class="someone_owner"><a href="#">Adam Kenisa</a></span>

        </div>

    </div>
</section>

<section class="home_wrapper">


</section>

<div class="home_wrapper">


    <div class="pages_bar">
        <a href="#" class="first_page"></a>
        <a href="#" class="privious_page"></a>
        <a href="#" class="current_page active_page"></a>
        <a href="#" class="next_page"></a>
        <a href="#" class="last_page"></a>
    </div>


    <div id="article_details">
        <div id="article_header">
            <div id="article_avatar" class="image_parent">
                <a href="#"><img src="<?php echo Yii::app()->baseUrl; ?>/images/ProfileImage/<?php echo $YTuong->Avatar; ?>"></a>
            </div>
            <div id="article_info">
                <div id="article_title" class="title">
                    <h2><?php echo $YTuong->TieuDe; ?></h2>
                </div>
                <div class="article_func">
                    <div class="information_function button_40">
                        <img class="icon_32" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/info-light.png">
                        <div class="information_details">
                            <div class="article_analysis">
                                <div class="analysis_view center-child">
                                    <img src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/View-light.png" class="icon_32">
                                    <span>200</span>
                                </div>
                                <div class="analysis_feedback center-child">
                                    <img src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/Note-light.png" class="icon_32">
                                    <span>200</span>
                                </div>
                                <div class="analysis_creative center-child">
                                    <img src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/Idea-light.png" class="icon_32">
                                    <span>200</span>
                                </div>
                            </div>
                            <div class="information_other">
                                <div class="information_title">
                                    <span>Thời gian đăng: </span>
                                </div>
                                <div class="information_value">
                                    <span>2/9/9563</span>
                                </div>
                            </div>

                        </div>

                    </div>
                    <div class="comment_function button_40">
                        <img class="icon_32" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/Comment-light.png">

                    </div>
                </div>
            </div>
        </div>
        <div id="article_content">
            <div>
                <img id="article_image" src="<?php echo Yii::app()->baseUrl; ?>/images/ArticleCover/<?php echo $YTuong->AnhBia; ?>" align="left">
                <h4 id="short_intro">
                    <?php echo $YTuong->GioiThieu; ?>
                </h4>

            </div>
        </div>
        <div id="full_article" <?php
        if (Yii::app()->user->id === $YTuong->NguoiDang) {
            echo ' contenteditable="true"';
        }
        ?>>

            <?php echo $YTuong->NoiDung; ?>
        </div>
<!--        <div class="rate_bar">
            <div class="level_rate level_rated"></div>
            <div class="level_rate level_rated"></div>
            <div class="level_rate level_rated"></div>
            <div class="level_rate level_rated"></div>
            <div class="level_rate level_rated"></div>
            <div class="level_rate level_rated"></div>
            <div class="level_rate level_rated"></div>
            <div class="level_rate level_rated"></div>
            <div class="level_rate"></div>
            <div class="level_rate"></div>
        </div>-->
    </div>


</div>

<div class="comment_level"> 
<!--    <div class="comment_nav">
        <div class="comment_field">
            <img class="field_icon icon_24" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/View-light.png">
            <span>Lượt xem</span>
        </div>
        <div class="comment_field">
            <img class="field_icon icon_24" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/Comment-light.png">
            <span>Số góp ý</span>
        </div>
        <div class="comment_field">
            <img class="field_icon icon_24" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/Idea-light.png">
            <span>Sáng tạo</span>
        </div>
        <div class="comment_field">
            <img class="field_icon icon_24" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/Note-light.png">
            <span>Thời gian</span>
        </div>
    </div>-->
<!--<hr/>-->
    <div class="comment_block">
        <div class="comment_person">
            <form name="comment" id="comment">
                <textarea name="content" id="comment_content"></textarea>
                <button class="button_base" id="submit-comment">Gửi</button>
            </form>
        </div>
        <div id="CommentBiz">
<!--        <div class="comment_person">
            <div class="comment_owner">
                <img src="<?php echo Yii::app()->baseUrl; ?>/images/People_demo.jpg">
            </div>
            <div class="comment_content">
                <div class="comment_text">
                    <p>
                        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                    </p>

                </div>
                <div class="comment_details">
                    <h4 class="owner_name">Adamson Kenisa</h4>
                    <div class="article_func">
                        <div class="information_function button_40">
                            <img class="icon_32" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/info-light.png">
                            <div class="information_details">

                            </div>
                        </div>
                        <div class="comment_function button_40">
                            <img class="icon_32" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/Comment-light.png">

                        </div>
                    </div>
                </div>

            </div>
            <div class="comment_reply">
                <div class="comment_child">
                    <div class="comment_owner">
                        <img src="<?php echo Yii::app()->baseUrl; ?>/images/People_demo.jpg">
                    </div>
                    <div class="comment_content">
                        <div class="comment_text">
                            <p>
                                Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                            </p>

                        </div>
                        <div class="comment_details">
                            <h4 class="owner_name">Adamson Kenisa</h4>
                            <div class="article_func">
                                <div class="information_function button_40">
                                    <img class="icon_32" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/info-light.png">
                                    <div class="information_details">

                                    </div>
                                </div>
                                <div class="comment_function button_40">
                                    <img class="icon_32" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/Comment-light.png">

                                </div>
                            </div>
                        </div>

                    </div>

                </div>
                <div class="comment_child">
                    <div class="comment_owner">
                        <img src="<?php echo Yii::app()->baseUrl; ?>/images/People_demo.jpg">
                    </div>
                    <div class="comment_content">
                        <div class="comment_text">
                            <p>
                                Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                            </p>

                        </div>
                        <div class="comment_details">
                            <h4 class="owner_name">Adamson Kenisa</h4>
                            <div class="article_func">
                                <div class="information_function button_40">
                                    <img class="icon_32" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/info-light.png">
                                    <div class="information_details">

                                    </div>
                                </div>
                                <div class="comment_function button_40">
                                    <img class="icon_32" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/Comment-light.png">

                                </div>
                            </div>
                        </div>

                    </div>

                </div>
                <div class="comment_child">
                    <div class="comment_owner">
                        <img src="<?php echo Yii::app()->baseUrl; ?>/images/People_demo.jpg">
                    </div>
                    <div class="comment_content">
                        <div class="comment_text">
                            <p>
                                Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                            </p>

                        </div>
                        <div class="comment_details">
                            <h4 class="owner_name">Adamson Kenisa</h4>
                            <div class="article_func">
                                <div class="information_function button_40">
                                    <img class="icon_32" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/info-light.png">
                                    <div class="information_details">

                                    </div>
                                </div>
                                <div class="comment_function button_40">
                                    <img class="icon_32" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/Comment-light.png">

                                </div>
                            </div>
                        </div>

                    </div>

                </div>
            </div>
        </div>
        <div class="comment_person">
            <div class="comment_owner">
                <img src="<?php echo Yii::app()->baseUrl; ?>/images/People_demo.jpg">
            </div>
            <div class="comment_content">
                <div class="comment_text">
                    <p>
                        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                    </p>

                </div>
                <div class="comment_details">
                    <h4 class="owner_name">Adamson Kenisa</h4>
                    <div class="article_func">
                        <div class="information_function button_40">
                            <img class="icon_32" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/info-light.png">
                            <div class="information_details">

                            </div>
                        </div>
                        <div class="comment_function button_40">
                            <img class="icon_32" src="<?php echo Yii::app()->baseUrl; ?>/images/Icons/Comment-light.png">

                        </div>
                    </div>
                </div>

            </div>

        </div>-->
        </div>
    </div>
</div>
<!--<div class="comment-form">
    <form name="comment" id="comment">
        <textarea name="content" id="comment_content"></textarea>
        <button id="submit-comment">Gửi</button>
    </form>
</div>-->

<script>
    function getComment(){
        URL = '<?php echo Yii::app()->createUrl('User/GetComment', array('Id' => $YTuong->Id)); ?>';
        $.post(URL, {}, function(data){
            $('#CommentBiz').html(data);
        });
    }
    $(document).ready(function() {
        getComment();
        CKEDITOR.replace('comment_content');
        $('#submit-comment').click(function(e) {
            e.preventDefault();
            var content = CKEDITOR.instances.comment_content.getData();
            URL = '<?php echo Yii::app()->createUrl('User/AddComment', array('Id' => $YTuong->Id)); ?>';
            $.post(URL, {content: content}, function(result) {
                getComment();
            });
        });
        $('#full_article').blur(function() {
            var data = $(this).html();
            URL = '<?php echo Yii::app()->createUrl('User/SaveArticleChanges', array('Id' => $YTuong->Id)); ?>';
            $.post(URL, {content: data}, function(result) {
                if (result !== 'success') {
                    alert('Có lỗi, không lưu thay đổi được. Vui lòng thử lại sau');
                }
            });
        });
    });
</script>